//
//  LiuToolBarView.swift
//  LiuWeiBo
//
//  Created by 刘晓晨 on 2017/3/30.
//  Copyright © 2017年 刘晓晨. All rights reserved.
//

import UIKit

class LiuToolBarView: UIView {

    //viewModel
    var statuse:LiustatuseViewModel? {
        didSet {
            retweetLabel.setTitle(statuse?.repostsCountStr, for: .normal)
            commentLabel.setTitle(statuse?.commentsCountStr, for: .normal)
            unlikeLabel.setTitle(statuse?.attitudesCountStr, for: .normal)
        }
    }
    
    lazy var retweetLabel:UIButton = {
        let button = UIButton(titleStr: "转发", image: "timeline_icon_retweet", fontSzie: 12)
        return button
    }()
    
    lazy var commentLabel:UIButton = {
        let button = UIButton(titleStr: "评论", image: "timeline_icon_comment", fontSzie: 12)
        return button
    }()
    
    lazy var unlikeLabel:UIButton = {
        let button = UIButton(titleStr: "赞", image: "timeline_icon_unlike", fontSzie: 12)
        return button
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setupUI() {
        backgroundColor = UIColor.white
        
        addSubview(retweetLabel)
        addSubview(commentLabel)
        addSubview(unlikeLabel)
        
        //添加分割线
        let firstSeparatorView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        let secondSeparatorView = UIImageView(image: UIImage(named: "timeline_card_bottom_line"))
        addSubview(firstSeparatorView)
        addSubview(secondSeparatorView)
        
        //自动布局
        retweetLabel.snp.makeConstraints { (make) in
            make.top.left.bottom.equalTo(self)
            make.width.equalTo(commentLabel)
        }
        
        commentLabel.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview()
            make.width.equalTo(unlikeLabel)
            make.left.equalTo(retweetLabel.snp.right)
        }
        
        unlikeLabel.snp.makeConstraints { (make) in
            make.top.right.bottom.equalToSuperview()
            make.left.equalTo(commentLabel.snp.right)
        }
        
        firstSeparatorView.snp.makeConstraints { (make) in
            make.centerX.equalTo(retweetLabel.snp.right)
            make.centerY.equalToSuperview()
        }
        
        secondSeparatorView.snp.makeConstraints { (make) in
            make.centerX.equalTo(commentLabel.snp.right)
            make.centerY.equalToSuperview()
        }
        
    }

}
